<template>
  <sv-page>
    <view class="favlib">
      <!-- 列表 -->
      <view class="cu-list menu sm-border sv-cu-list">
        <view
          class="cu-item arrow"
          v-for="item in favLibData"
          :key="item.lib_id"
          @click="onLib(item)"
        >
          <view class="content">
            <text class="cuIcon-circlefill text-grey"></text>
            <text class="text-cyan">{{ item.lib_name }}</text>
          </view>
        </view>
      </view>
    </view>
  </sv-page>
</template>

<script setup>
import { ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { store } from '@/uni_modules/sv-id-pages/common/store'
import { favLibList } from '@/service/api/record'

const favLibData = ref([])

onLoad(async () => {
  uni.showLoading({ title: '加载中' })
  const favLibRes = await favLibList({ user_id: store.userInfo._id })
  favLibData.value = favLibRes.data || []
  uni.hideLoading()
})

function onLib(item) {
  uni.navigateTo({
    url: `/pages/lib/lib?lib_id=${item.lib_id}`
  })
}
</script>

<style lang="scss"></style>
